<?php 
$days = 10;
	$chartData = ClassRegistry::init('Stats.Hit')->getLastXDays($days);

		//-------------------------------
		//Formatting the data for Chart
		//-------------------------------

		$time = time();
		for($i=$days; $i>=1; $i--)
		{
			$date = date('Y-m-d',$time);
			if(array_key_exists($date,$chartData))
				$formatted[$time] = $chartData[$date];
		else
			$formatted[$time] =0;
			$time = $time - 3600*24;
		}
		
		ksort($formatted);
		foreach($formatted as $key=>$value)
		{
			$date=date('d-M',$key);
			$formatted_data[$date]=$value;

		}

		//---------------------------------
		//Code to show Chart
		//---------------------------------

		 $flashChart->begin(1000, 250, 'Day', 'Hits');
		 $flashChart->title('Hits for Last '.$days.' Days');
		 $flashChart->labels(array_keys($formatted_data));
			 
		 $data = array(
				'Hits' => array(
						 'color' => '#00aa42',
						 'font_size' => 11,
						 'data' => $formatted_data,
						 'graph_style' => 'lines',
								)
					);
		  $flashChart->setData($data);    
		  echo $flashChart->render(); 
		  ?>